package org.cuatrovientos.empirefleet;

/**
 * 	Represents a generic space ship
 * @author Axel Louis
 * @greets Pello Altadill
 */
public class SpaceShip {
	private int bombs;
	private int type;
	private int speed;
	
	/**
	 * Constructor
	 * @param type
	 */
	public SpaceShip (int type)  {
		this.setType(type);
	}
	
	/**
	 * Only for bomber (type==2)
	 * Drops a bomb
	 * @return bomb damage
	 */
	public int bomb () {
		if (getType() == 2)
			return 5;
		else
			return 0;
	}
	
	/**
	 * Only tie advanced and bombers
	 * Fires ION cannon
	 * @return damage
	 */
	public int fireIonCanon () {
		if (getType()==1 || getType()==2) 
			return 3;
		else 
			return 0;
	}
	
	/**
	 * Fires Laser
	 * @return laser damage depending of type
	 */
	public int fireLaser () {
		int damage = 0;
		switch (getType()) {
			case 0: damage = 1;
					break;
			case 1: damage = 2;
					break;
			case 2: damage = 3;
					break;
			default:damage = 0;
					break;
		}
		
		return damage;
	}
	
	/**
	 * Move, more or less depending on type
	 * @return positions
	 */
	public int move () {
		int movement = 0;
		switch (getType()) {
			case 0: movement = 1;
					break;
			case 1: movement = 3;
					break;
			case 2: movement = 2;
					break;
			default:movement = 0;
					break;
		}
		
		return movement;
	}

	int getBombs() {
		return bombs;
	}

	void setBombs(int bombs) {
		this.bombs = bombs;
	}

	int getType() {
		return type;
	}

	void setType(int type) {
		this.type = type;
	}

	int getSpeed() {
		return speed;
	}

	void setSpeed(int speed) {
		this.speed = speed;
	}

	@Override
	public String toString() {
		return "SpaceShip [bombs=" + bombs + ", type=" + type + ", speed="
				+ speed + "]";
	}
}
